function [theta,j_history] = gradientDescent(x,y,theta,alpha,num_iters)
	m = length(y);
	j_history = zeros(num_iters,1);
	j = zeros(m,1);
	for iter = 1:num_iters
		j = x*theta - y;
		temp1 = theta(1) - alpha * (1/m) * sum(j .*x(:,1));
		temp2 = theta(2) - alpha * (1/m) * sum(j .*x(:,2));
		theta(1) = temp1;
		theta(2) = temp2;
		j_history(iter) = computeCost(x,y,theta);
	end
end

